from . import admin
from app.models import Article, Category
from flask import render_template, request
from app.some_func import wapper
# 控制台页面
@admin.get('/welcome')
@wapper
def welcome():
    article_pagination = Article.query.order_by(
        Article.id.desc()).paginate(
        page=int(request.args.get('page', 1)), per_page=10,
        error_out=False)
    article_count = Article.query.count()
    category_count = Category.query.count()
    return render_template('admin/console.html', article_count=article_count, category_count=category_count,
    articles=article_pagination.items)